﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;

namespace SalienceEngineDemo
{
    public class SettingsSerializer
    {
        public SettingsSerializer()
        {
        }
        
        public void Serialize(string filename, Settings serial)
        {
            Stream stream = File.Open(filename, FileMode.Create);
            BinaryFormatter bFormatter = new BinaryFormatter();
            bFormatter.Serialize(stream, serial);
            stream.Close();
        }

        public Settings Deserialize(string filename)
        {
            Settings serial;
            Stream stream = File.Open(filename, FileMode.Open);
            BinaryFormatter bFormatter = new BinaryFormatter();
            serial = (Settings)bFormatter.Deserialize(stream);
            stream.Close();
            return serial;
        } 
    }
}